<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script>
        haystack = "aaaaa", needle = "bba"

        var strStr = function(haystack, needle) {
            return haystack.indexOf(needle)
        };
        console.log(strStr(haystack,needle ));

    </script>
</body>
</html>